
// MFCD3D11TestDoc.h : interface of the CMFCD3D11TestDoc class
//


#pragma once
#include "IO/XYZFileIO.h"
#include "Utility/RayTracingHM.h"

class CMFCD3D11TestDoc : public CDocument
{
protected: // create from serialization only
	CMFCD3D11TestDoc();
	DECLARE_DYNCREATE(CMFCD3D11TestDoc)

// Attributes
public:
	CString m_strMXYZFiles;
	CString m_strMAFMSliceFiles;
	int m_iNormalWndSize;
	NORMALESTIMATEMETHOD m_iCurNormEstMethod;
	float m_fGaussSigma;

	NORMALESTIMATEMETHOD m_iCurNormEstMethodMFiles;
	int m_iNFKernelSizeMFiles;
	float m_fGaussSigmaMFiles;
	float m_fSampleWidthMFiles;
	float m_fSampleHeightMfiles;
// Operations
public:
	inline CXYZFileIO* GetXYZFile() {return &m_XYZFile;}

	BOOL ProcessXYZFile();
	BOOL EstimateNormMFiles();
	BOOL SetNormalWndSize(int iSize);
	BOOL SetNFGaussianSigma(float fSigma);
	BOOL RayTraceCurXYZFileStatistics();
	BOOL RaytracingVirtualGonioTest();
	BOOL RaytracingVirtualGonioTest_MFiles();
	BOOL ComputeWaveOptic();
	BOOL ComputeWaveOpticMFiles();
	BOOL GenerateHMFromAFM1DSlices(CXYZFileIO* pXYZFile);

	inline float getRTScaleRatio() {return m_fRTScaleRatio;}
	inline float getRTThetaAng() {return m_fRTThetaAng;}
	inline float getRTPhiAng() {return m_fRTPhiAng;}
	inline void setRTScaleRatio(float fRatio) {m_fRTScaleRatio = fRatio;}
	inline void setRTThetaAng(float fTheta) {m_fRTThetaAng = fTheta;}
	inline void setRTPhiAng(float fPhi) {m_fRTPhiAng = fPhi;}

	static void OutputDebugInfoThread(UtilityString& strDbgInfo)
	{
		CString* pOutputStr = new CString(strDbgInfo.GetCharStr());
		theApp.PostThreadMessage(WM_OUTPUT_DEBUGMSGTHREAD, WPARAM(pOutputStr),0);
	}
// Overrides
public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
#ifdef SHARED_HANDLERS
	virtual void InitializeSearchContent();
	virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS

// Implementation
public:
	virtual ~CMFCD3D11TestDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CXYZFileIO m_XYZFile;
	//ray tracing heightmap test!
	float m_fRTScaleRatio;
	float m_fRTThetaAng;
	float m_fRTPhiAng;
// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()

#ifdef SHARED_HANDLERS
	// Helper function that sets search content for a Search Handler
	void SetSearchContent(const CString& value);
#endif // SHARED_HANDLERS
public:
	virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
public:
	HWND m_hMainWnd;
	UtilityString m_strLoadXYZFN;
//static function for multitheading!
	static DWORD _stdcall LoadXYZFileFromFile(void* pThis);
//static function for multitheading!
	static DWORD _stdcall EstimateNormXYZFile(void* pThis);
//static function for multitheading!
	static DWORD _stdcall EstimateNormMultiXYZFiles(void* pThis);
//static function for multitheading!
	static DWORD _stdcall ComputeWaveOpticSingleFile(void* pThis);
//static function for multitheading!
	static DWORD _stdcall ComputeWaveOpticMultipleFiles(void* pThis);
//static function for multitheading!
	static DWORD _stdcall SetNormalWndSizeThread(void* pThis);
//static function for multithreading
	static DWORD _stdcall SetNFGaussianSigmaThread(void* pThis);
//static function for multithreading
	static DWORD _stdcall RayTraceCurXYZFileStatisticsThread(void* pThis);
//static function for multithreading
	static DWORD _stdcall RaytracingVirtualGonioTestThread(void* pThis);
//static function for multithreading
	static DWORD _stdcall RaytracingVirtualGonioTestMFilesThread(void* pThis);

};
